/**
 *    @file       czlib.h
 *
 *    @brief      
 *    @details
 *
 *    @version    1.0
 *    @date       01/25/2014 10:15:40 PM
 *
 *    @author     Theophilus (), wangtf418@gmail.com 
 */
#ifndef _BF_CZLIB_H_
#define _BF_CZLIB_H_
#include <string>
#include "comdef.h"

class czlib
{
public:
	czlib();
	~czlib();

public:
	///destlen > (srclen + 12) * 100.1%
	static bf_int_t compress(const bf_uchar_t *src, bf_ulong_t srclen, bf_uchar_t *dest, bf_ulong_t &destlen);
	///If destlen is not enough, uncompress will return BF_ERROR
	static bf_int_t uncompress(const bf_uchar_t *src, bf_ulong_t strlen, bf_uchar_t *dest, bf_ulong_t &destlen);
};

class czlib_compress
{
public:
	czlib_compress();
	~czlib_compress();

public:
	bf_int_t compress(const bf_uchar_t *src, bf_ulong_t srclen);
	inline std::string & get_buf()
	{
		return m_buf;
	}

private:
	std::string m_buf;
};

class czlib_uncompress
{
public:
	czlib_uncompress();
	~czlib_uncompress();

public:
	bf_int_t uncompress(const bf_uchar_t *src, bf_ulong_t srclen, bf_ulong_t destlen = 0);
	inline std::string & get_buf()
	{
		return m_buf;
	}

private:
	std::string m_buf;
};

#endif

